package com.lei.springbootpractice.service;

import com.lei.springbootpractice.dao.EmpDao;
import com.lei.springbootpractice.pojo.EmpPojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmpService  {
    @Autowired
    EmpDao empDao;

    public void addEmp(String empno,
                       String ename,
                       int age,
                       String deptno,
                       double sal,
                       String gender){
        empDao.insert(new EmpPojo(empno,ename,age,deptno,sal,gender));
    }

    // EmpService.java 新增方法
    public EmpPojo getEmpByEmpno(String empno) {
        return empDao.selectById(empno);
    }

    public boolean validateLogin(String empno, String deptno) {
        EmpPojo emp = getEmpByEmpno(empno);
        return emp != null && emp.getDeptno().equals(deptno);
    }
}
